//
//  GangCaiTableViewCell.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/6/1.
//

#import "GangCaiTableViewCell.h"
#import "CommonUtil.h"
#import "AccuracyView.h"

@interface GangCaiTableViewCell()

@property (strong, nonatomic) UIImageView * iconImageView;
@property (strong, nonatomic) UILabel * nameLabel;
@property (strong, nonatomic) UILabel * typeLabel;
@property (strong, nonatomic) UILabel * resultLabel1;
@property (strong, nonatomic) UILabel * resultLabel2;
@property (strong, nonatomic) AccuracyView * accuracyView;
@property (strong, nonatomic) UIView * lineView;
@property (strong, nonatomic) UIButton * zanBtn;
@end

@implementation GangCaiTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {

        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.iconImageView];
        [self.contentView addSubview:self.typeLabel];
        [self.contentView addSubview:self.nameLabel];
        [self.contentView addSubview:self.resultLabel1];
        [self.contentView addSubview:self.resultLabel2];
        [self.contentView addSubview:self.accuracyView];
        [self.contentView addSubview:self.zanBtn];
        [self.contentView addSubview:self.lineView];
        
        self.nameLabel.text = @"三肖";
        self.resultLabel1.text = @"战绩:0对0";
        self.resultLabel2.text = @"第0期:-鼠-虎-兔-";
        
        [self.nameLabel sizeToFit];
        [self.resultLabel1 sizeToFit];
        

        
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.lineView.bottom = self.height;
}


- (void)zanBtnClick:(UIButton *)sender{
    sender.selected = !sender.selected;
}


#pragma mark - lazy

-(UIImageView *)iconImageView{
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"statistics_default.jpg"]];
        _iconImageView.layer.cornerRadius = AD(35);
        _iconImageView.clipsToBounds = YES;
        _iconImageView.frame = CGRectMake(AD(5), self.typeLabel.bottom, AD(70), AD(70));
    }
    return _iconImageView;
}

-(UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(_iconImageView.right + AD(3), self.typeLabel.bottom, AD(200), AD(20))];
        _nameLabel.textColor = [UIColor blackColor];
        _nameLabel.font = [UIFont boldSystemFontOfSize:AD(16)];
    }
    return _nameLabel;
}



-(UILabel *)resultLabel1{
    if (!_resultLabel1) {
        _resultLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(_nameLabel.left, self.nameLabel.bottom, AD(200), AD(15))];
        _resultLabel1.textColor = [UIColor blackColor];
        _resultLabel1.font = [UIFont systemFontOfSize:AD(12)];
    }
    return _resultLabel1;
}



-(UILabel *)resultLabel2{
    if (!_resultLabel2) {
        _resultLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(_nameLabel.left, self.resultLabel1.bottom, AD(200), AD(20))];
        _resultLabel2.textColor = [UIColor blackColor];
        _resultLabel2.font = [UIFont boldSystemFontOfSize:AD(16)];
    }
    return _resultLabel2;
}


-(UILabel *)typeLabel{
    if (!_typeLabel) {
        _typeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, AD(40), AD(20))];
        _typeLabel.textColor = [UIColor whiteColor];
        _typeLabel.font = [UIFont boldSystemFontOfSize:AD(12)];
        _typeLabel.textAlignment = NSTextAlignmentCenter;
        _typeLabel.layer.cornerRadius = AD(5);
        _typeLabel.clipsToBounds = YES;
        _typeLabel.backgroundColor = RGB(255.0, 89.0, 117.0);
        _typeLabel.hidden = YES;
    }
    return _typeLabel;
}

-(AccuracyView *)accuracyView{
    if (!_accuracyView) {
        _accuracyView = [[AccuracyView alloc] initWithFrame:CGRectMake(0, self.iconImageView.bottom, SCREEN_WIDTH-AD(80), AD(20))];
    }
    return _accuracyView;
}
-(UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, AD(1))];
        _lineView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    }
    return _lineView;
}

-(UIButton *)zanBtn{
    if (!_zanBtn) {
        _zanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_zanBtn setTitle:@"113" forState:UIControlStateNormal];
        [_zanBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        [_zanBtn setTitleColor:RGB(255.0, 90.0, 117.0) forState:UIControlStateSelected];
        _zanBtn.titleLabel.font = [UIFont systemFontOfSize:AD(12)];
        [_zanBtn addTarget:self action:@selector(zanBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_zanBtn setImage:[UIImage imageNamed:@"icon_zan_normal"] forState:UIControlStateNormal];
        [_zanBtn setImage:[UIImage imageNamed:@"icon_zan_select"] forState:UIControlStateSelected];
        _zanBtn.frame = CGRectMake(_accuracyView.right + AD(10), _accuracyView.top, AD(50), AD(20));
//        _zanBtn.titleEdgeInsets = UIEdgeInsetsMake(AD(0), -AD(30), 0, 0);
//        _zanBtn.imageEdgeInsets = UIEdgeInsetsMake(-AD(0), AD(12), 0, 0);
    }
    return _zanBtn;
}


@end
